//
//  OosImage.m
//  Oos4ios
//
//  Created by Pablo Gonzalez on 3/17/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import <oos4ios/Model/OosImage.h>


@implementation OosImage

@synthesize size = current;

static NSString *fetchPredicate = @"identifier = %@";
static NSString *urlPredicate = @"urlString = %@";

+ (OosImage *) imageFromIdentifier: (NSString *) identifier
{
    
    OosImage *result = [super objectWithPredicate: fetchPredicate, identifier];
    
    if (!result) {
        result = [super create];
        result.identifier = identifier;
    }
    
    return result;
}

+ (OosImage *) imageFromPath: (NSString *) path
{
    
    OosImage *result = [super objectWithPredicate: urlPredicate, path];
    
    if (!result) {
        result = [super create];
        result.urlString = path;
    }
    
    return result;
}

- (void) setSize:(OosImageSize *)size
{
	current = size;
	self.urlString = [size pathFromPath: self.urlString];
}

@end
